/*
 * DoProcedure.h
 *
 *  Created on: Oct 18, 2012
 *      Author: wtao
 */

#ifndef DOPROCEDURE_H_
#define DOPROCEDURE_H_

#include "_DoCompositeObject.h"

class DoProcedure : public onTokenListener, public _DoCompositeObject
{
protected:
	DoProcedure(const DoProcedure&);
	DoProcedure& operator=(const DoProcedure&);

	bool mExecute;
public:
	DoProcedure();
	virtual ~DoProcedure();

	virtual bool executable() const {
		return mExecute;
	}

	void enableExecutable () {
		mExecute = true;
	}

	virtual onTokenListener::eContinueParse onChar(int currChar) {
		if (currChar == '}')
			return onTokenListener::eStop;
		return onTokenListener::eContinue;
	}

	virtual void onToken(CRefPtr< _DoObject > token) {
		if (token->type() == _DoObject::eComment)
			return;
		add(token);
	}

	virtual std::string _debug_dump() const{
		std::ostringstream oss;

		oss << mText << "{";
		oss << _DoCompositeObject::_debug_dump();
		oss << "}";

		return oss.str();
	}

	virtual void execute(DevilSemantic &semantic);
};

#endif /* DOPROCEDURE_H_ */
